unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Buttons, ExtCtrls, StdCtrls, Db, ADODB, Grids, DBCtrls, DBGrids, CRGrid,
  ElXPThemedControl, ElTreeInplaceEditors, ElTree, ElDBTree, ElDBTreeGrids,
  uniDBGrid;

type
  TForm1 = class(TForm)
    ADOTable1: TADOTable;
    DataSource1: TDataSource;
    UniDBGrid1: TUniDBGrid;
    dbmmoco: TDBMemo;
    dbnvgr1: TDBNavigator;
    edt1: TEdit;
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;


const
 BMPstarts = '424D'; //BM

var
  Form1: TForm1;

implementation
uses jpeg;
{$R *.DFM}

function JpegStartsInBlob(PicField:TBlobField):integer;
var
 bS     : TADOBlobStream;
 buffer : Word;
 hx     : string;
begin
 Result := -1;
 bS := TADOBlobStream.Create(PicField, bmRead);
 try
  while (Result = -1) and (bS.Position + 1 < bS.Size) do begin
   bS.ReadBuffer(buffer, 1);
   hx:=IntToHex(buffer,2);
   if hx = 'FF' then begin
     bS.ReadBuffer(buffer, 1);
     hx:=IntToHex(buffer,2);
     if hx = 'D8' then Result := bS.Position - 2
     else if hx = 'FF' then bS.Position := bS.Position-1;
   end;//if
  end;//while
 finally
  bS.Free
 end; //try
end;






procedure TForm1.FormCreate(Sender: TObject);
var sDBPath, sCons: string;
begin
//change the sDBPath to point to your database!
//sDBPath := 'c:\delphi.mdb';
sCons :='Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;'+
  'Data Source=delphi.mdb;'+    // change access filename here
  'Mode=Share Deny None;Extended Properties="";Jet OLEDB:System database="";'+
  'Jet OLEDB:Registry Path="";Jet OLEDB:Database Password="";Jet OLEDB:Engine Type=5;'+
  'Jet OLEDB:Database Locking Mode=1;Jet OLEDB:Global Partial Bulk Ops=2;'+
  'Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New Database Password="";'+
  'Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;'+
  'Jet OLEDB:Don''t Copy Locale on Compact=False;'+
  'Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False ';
ADOTable1.ConnectionString := sCons;
ADOTable1.TableName := 'codeitems';
//qry1.ConnectionString:= sCons;
//qry1.SQL.Text:='select * from codeitems';


//DataSource1.DataSet := qry1;
//taSource1.DataSet := ADOTable1;
//Grid1.DataSource := DataSource1;

ADOTable1.Active:=True;
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
ADOTable1.Active:=False;
end;

end.
